import os from "os";

// 当前 IP 地址
export const getIP = () => {
  let needHost = ""; // 打开的host
  const network = os.networkInterfaces();
  for (let key in network) {
    let net = network[key].find(
      (n) => n.family === "IPv4" && n.address !== "127.0.0.1" && !n.internal
    );
    if (net) {
      needHost = net.address;
      break;
    }
  }
  return needHost || "localhost";
};
